Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: aliok The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
KEDA metadata must emit SASL plaintext configuration when the mechanism is omitted.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Makes run.kafka.sasl.mechanism optional, defaulting omitted values to SASL/PLAIN.
Changes:
- Relaxes mechanism validation.
- Maps empty mechanisms to KEDA
plaintext. - Updates tests and documentation.
A critical issue remains: empty mechanisms are not emitted in KEDA ScaledObject metadata.
| File | Reviewed changes |
|---|---|
pkg/keda/kafka_scaling.go |
Adds empty-mechanism mapping. |
pkg/keda/kafka_scaling_test.go |
Tests the mapping. |
pkg/keda/deployer_unit_test.go |
Removes obsolete required-mechanism coverage. |
pkg/functions/function.go |
Makes mechanism validation conditional. |
pkg/functions/function_test.go |
Tests empty mechanisms. |
docs/reference/func_yaml.md |
Documents the optional field and default. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }, | ||
| wantErr: "run.kafka.sasl.mechanism is required", | ||
| }, | ||
| { |
There was a problem hiding this comment.
nit: the doc comment on this test (line 355) is out of date after fa940e7. buildScaledObject now writes sasl whenever the SASL block is set, not only for a non-empty mechanism. Can you reword or drop that clause?
| case "SCRAM-SHA-512": | ||
| return "scram_sha512" | ||
| case "PLAIN": | ||
| case "PLAIN", "": |
There was a problem hiding this comment.
nit (follow-up is fine): we document "defaults to PLAIN", but func never sets that default. It only works because func-go happens to use PLAIN, and seven comments repeat that fact (three in code, four in tests). A related comment already went stale in this PR (deployer_unit_test.go:355). What about one helper, e.g. KafkaSASL.EffectiveMechanism() returning "PLAIN" for "", used by the three env-wiring sites and kedaSASLType? Then the container and the scaler read the same value from func, and most of those comments can go.
| triggerMeta["sasl"] = kedaSASLType(kafka.SASL.Mechanism) | ||
| if kafka.SASL != nil { | ||
| // Emit sasl whenever the SASL block is configured, not only when a | ||
| // mechanism is named: func-go's Kafka runtime treats a present SASL |
There was a problem hiding this comment.
nit: func-go never sees the SASL block. It turns SASL on from KAFKA_SECURITY_PROTOCOL (kafka/security.go). SASL != nil works here only because validation ties the block to SASL_*. Gating on SecurityProtocol would match the runtime exactly and match the tls gate just above.
| } | ||
|
|
||
| // TestBuildScaledObject_EmptyMechanismEmitsPlaintext covers the empty-mechanism | ||
| // SASL config this PR newly accepts: func-go defaults an omitted mechanism to |
There was a problem hiding this comment.
nit: "this PR" won't mean much once this merges. Maybe "an omitted mechanism" instead.
| - `skipVerify`: skip broker certificate verification (development only). | ||
| - `sasl`: SASL configuration, required for `SASL_PLAINTEXT` and `SASL_SSL`. | ||
| - `mechanism`: one of `PLAIN`, `SCRAM-SHA-256`, `SCRAM-SHA-512`. | ||
| - `mechanism`: one of `PLAIN`, `SCRAM-SHA-256`, `SCRAM-SHA-512`. Optional; defaults to `PLAIN` when unset. |
There was a problem hiding this comment.
nit: the jsonschema description on KafkaSASL.Mechanism (pkg/functions/function.go:217) should mention the default too (e.g. "... Defaults to PLAIN."), so editor tooltips match this doc. Needs a schema regen.

Changes
Follow-up to review feedback on #4069 (thanks @gauron99); reproduced on a live
cluster.
run.kafka.sasl.mechanismoptional. func-go's Kafka runtimedefaults an empty mechanism to
PLAIN, so a SASL/PLAIN broker deployed andconsumed fine before
scale.kedalanded. Requiring the field broke that configon every deployer (raw, knative, keda), not only keda. Validation now
constrains only a non-empty value to the mechanisms both sides understand, and
kedaSASLTypemaps""to KEDA'splaintextso the scaler authenticates thesame way the function container does.
/kind bug
Relates to #4069
Release Note
Docs